<script setup>
import {useSysOrganizationTree} from "@/composables/sys/organization.js";
const value = defineModel()

const props = defineProps({
  topDisabled: {
    type: Boolean,
    default: false
  }
})

const {data, isLoading} = useSysOrganizationTree()
const treeData = computed(() => {
  return [
    {
      name: '顶级',
      code: '-',
      children: data.value?.data || [],
      disabled: props.topDisabled
    }
  ]
})

</script>

<template>
  <n-tree-select
      default-expand-all
      key-field="code"
      label-field="name"
      :loading="isLoading"
      :options="treeData"
      v-bind="$attrs"
      v-model:value="value"
  />
</template>

<style scoped>

</style>